<template>
	<view class="daily-mission">
		<!-- 红色头部背景 -->
		<view class="header-section">
			<image 
				class="header-bg" 
				src="/static/dailyMission/top.png" 
				mode="widthFix"
				placeholder="请添加头部背景图片"
			></image>
			<view class="header-content">
				<view class="header-left">
					<text class="header-title">我的积分</text>
					<view class="points-row">
						<text class="points-number">1000</text>
						<button class="points-detail-btn">积分明细</button>
					</view>
				</view>
				
			</view>
		</view>

		<!-- 每日签到区域 -->
		<view class="checkin-section">
			<view class="section-title">
				<text>每日签到</text>
			</view>
			<view class="checkin-days">
				<view 
					class="day-item" 
					v-for="(day, index) in checkinDays" 
					:key="index"
					:class="{ 'today': day.isToday, 'checked': day.isChecked }"
				>
					<view class="day-coin">
						<text class="coin-star">★</text>
					</view>
					<text class="day-points">+{{ day.points }}</text>
					<text class="day-label">{{ day.label }}</text>
				</view>
			</view>
			<button class="checkin-btn">立即签到</button>
		</view>

		<!-- 积分任务区域 -->
		<view class="tasks-section">
			<view class="section-title">
				<text>积分任务</text>
			</view>
			<view class="task-list">
				<view 
					class="task-item" 
					v-for="(task, index) in tasks" 
					:key="index"
				>
					<view class="task-left">
						<image 
							class="task-icon" 
							:src="task.iconSrc" 
							mode="aspectFill"
							placeholder="请添加任务图标"
						></image>
						<view class="task-info">
							<view class="task-title">
								<text>{{ task.title }}</text>
								<text class="task-points">+{{ task.points }}</text>
								<text class="star-icon">★</text>
							</view>
							<text class="task-desc">{{ task.description }}</text>
						</view>
					</view>
					<button 
						class="task-btn" 
						:class="{ 'completed': task.isCompleted }"
					>
						{{ task.isCompleted ? '已完成' : '去完成' }}
					</button>
				</view>
			</view>
		</view>

		<!-- 热门兑换区域 -->
		<view class="exchange-section">
			<view class="section-header">
				<text class="section-title">热门兑换</text>
				<view class="view-more">
					<text>查看更多 ></text>
				</view>
			</view>
			<view class="exchange-grid">
				<view 
					class="exchange-item" 
					v-for="(item, index) in exchangeItems" 
					:key="index"
				>
					<image 
						class="exchange-image" 
						:src="item.imageSrc" 
						mode="aspectFill"
						placeholder="请添加兑换商品图片"
					></image>
					<text class="exchange-title">{{ item.title }}</text>
					<view class="exchange-price">
						<text class="price-text">{{ item.points }}积分</text>
						<text class="star-icon">★</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				checkinDays: [
					{ points: 5, label: '今天', isToday: true, isChecked: false },
					{ points: 10, label: '第2天', isToday: false, isChecked: false },
					{ points: 15, label: '第3天', isToday: false, isChecked: false },
					{ points: 20, label: '第4天', isToday: false, isChecked: false },
					{ points: 30, label: '第5天', isToday: false, isChecked: false },
					{ points: 40, label: '第6天', isToday: false, isChecked: false },
					{ points: 50, label: '第7天', isToday: false, isChecked: false }
				],
				tasks: [
					{
						title: '注册新用户',
						points: 10,
						description: '每位用户注册成为新会员可获得10积分',
						isCompleted: true,
						iconSrc: '/static/dailyMission/registerMore.png'
					},
					{
						title: '商城购物',
						points: 1,
						description: '消费满10元,可获得1积分',
						isCompleted: false,
						iconSrc: '/static/dailyMission/shopping.png'
					}
				],
				exchangeItems: [
					{
						title: 'xiaol',
						points: 1,
						imageSrc: ''
					},
					{
						title: '先锋男士小样试用装',
						points: 109,
						imageSrc: '/static/dailyMission/img2.png'
					}
				]
			};
		},
		methods: {
			checkin() {
				// 签到逻辑
				console.log('签到');
			},
			completeTask(taskIndex) {
				// 完成任务逻辑
				console.log('完成任务:', taskIndex);
			},
			exchangeItem(itemIndex) {
				// 兑换商品逻辑
				console.log('兑换商品:', itemIndex);
			}
		}
	}
</script>

<style lang="scss">
.daily-mission {
	background-color: #f5f5f5;
	min-height: 100vh;
}

.header-section {
	position: relative;
	width: 100%;
	height: 200px;
	overflow: hidden;

	.header-bg {
		width: 100%;
		height: 100%;
		background-color: #ff4757;
	}

	.header-content {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		padding: 20px 16px;
	}

	.header-left {
		.header-title {
			color: #fff;
			font-size: 16px;
			font-weight: bold;
			display: block;
			margin-bottom: 0px;
		}

		.points-row {
			display: flex;
			align-items: center;
			gap: 12px;
		}

		.points-number {
			color: #fff;
			font-size: 32px;
			font-weight: bold;
		}

		.points-detail-btn {
			background-color: transparent;
			border: 1px solid #fff;
			color: #fff;
			border-radius: 16px;
			padding: 1px 12px;
			font-size: 12px;
			margin-left: 5px;
		}
	}

	.header-right {
		.nav-icons {
			display: flex;
			gap: 8px;

			.nav-icon {
				color: #fff;
				font-size: 16px;
			}
		}
	}
}

.checkin-section {
	background-color: #fff;
	margin: 16px;
	border-radius: 12px;
	padding: 20px;
	margin-top: -105px;
	position: relative;
	z-index: 2;

	.section-title {
		font-size: 18px;
		color: #333;
		font-weight: bold;
		margin-bottom: 10px;
	}

	.checkin-days {
		display: flex;
		justify-content: space-between;
		margin-bottom: 14px;
	}

	.day-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 4px;

		.day-coin {
			width: 40px;
			height: 40px;
			background-color: #ffd700;
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
			box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);

			.coin-star {
				color: #fff;
				font-size: 16px;
			}
		}

		.day-points {
			font-size: 12px;
			color: #ff4757;
			font-weight: bold;
			text-shadow: 0 1px 2px rgba(255, 71, 87, 0.3);
		}

		.day-label {
			font-size: 10px;
			color: #666;
			text-shadow: 0 1px 2px rgba(102, 102, 102, 0.2);
		}

		&.today .day-coin {
			background-color: #ff4757;
			box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
		}

		&.checked .day-coin {
			background-color: #ccc;
			box-shadow: 0 2px 8px rgba(204, 204, 204, 0.4);
		}
	}

	.checkin-btn {
		width: 80%;
		background-color: #ff4757;
		color: #fff;
		border: none;
		border-radius: 25px;
		padding: 4px;
		font-size: 16px;
		font-weight: bold;
	}
}

.tasks-section {
	background-color: #fff;
	margin: 16px;
	border-radius: 12px;
	padding: 20px;

	.section-title {
		font-size: 18px;
		color: #333;
		font-weight: bold;
		margin-bottom: 6px;
	}

	.task-list {
		display: flex;
		flex-direction: column;
		gap: 16px;
	}

	.task-item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 4px 0;
		border-bottom: 1px solid #f0f0f0;

		&:last-child {
			border-bottom: none;
		}

		.task-left {
			display: flex;
			align-items: center;
			flex: 1;
			gap: 12px;
		}

		.task-icon {
			width: 40px;
			height: 40px;
			background-color: #f0f0f0;
			border-radius: 8px;
		}

		.task-info {
			flex: 1;

			.task-title {
				display: flex;
				align-items: center;
				gap: 8px;
				margin-bottom: 4px;

				text {
					font-size: 16px;
					color: #333;
					font-weight: bold;
				}

				.task-points {
					color: #ff4757;
				}

				.star-icon {
					color: #ffd700;
					font-size: 12px;
				}
			}

			.task-desc {
				font-size: 14px;
				color: #666;
				line-height: 1.4;
			}
		}

		.task-btn {
			background-color: #ff4757;
			color: #fff;
			border: none;
			border-radius: 16px;
			padding: 4px 16px;
			font-size: 14px;

			&.completed {
				background-color: #ccc;
			}
		}
	}
}

.exchange-section {
	background-color: #fff;
	margin: 16px;
	border-radius: 12px;
	padding: 20px;

	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20px;

		.section-title {
			font-size: 18px;
			color: #333;
			font-weight: bold;
		}

		.view-more {
			text {
				font-size: 14px;
				color: #999;
			}
		}
	}

	.exchange-grid {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 16px;
	}

	.exchange-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 8px;

		.exchange-image {
			width: 100%;
			height: 120px;
			background-color: #f0f0f0;
			border-radius: 8px;
		}

		.exchange-title {
			font-size: 14px;
			color: #333;
			text-align: center;
			line-height: 1.3;
		}

		.exchange-price {
			display: flex;
			align-items: center;
			gap: 4px;

			.price-text {
				font-size: 14px;
				color: #ff4757;
				font-weight: bold;
			}

			.star-icon {
				color: #ffd700;
				font-size: 12px;
			}
		}
	}
}
</style>
